package com.azt.provider.impl;

import com.azt.api.pojo.CompanyAsset;
import com.azt.api.service.CompanyAssetService;
import com.azt.model.page.Pagination;
import com.azt.provider.mapper.CompanyAssetMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 企业资质
 * Created by LiQZ on 2017/4/18.
 */
@Service
public class CompanyAssetServiceImpl implements CompanyAssetService {

    @Autowired
    private CompanyAssetMapper companyAssetMapper;

    @Override
    public Pagination listPage(Integer pageNo, Integer pageSize, Map<String, Object> params) {
        Page<Object> startPage = PageHelper.startPage(pageNo, pageSize);
        PageHelper.orderBy("createtime desc");
        List<CompanyAsset> list = companyAssetMapper.selectByCondition(params);
        Pagination p = new Pagination(startPage, list);
        p.setList(list);
        return p;
    }

    @Override
    public void delete(Integer id) {
        CompanyAsset asset = new CompanyAsset();
        asset.setId(id);
        asset.setRemoved(1);
        companyAssetMapper.updateByPrimaryKeySelective(asset);
    }

    @Override
    public CompanyAsset get(Integer id) {
        return companyAssetMapper.selectAddCompanyInfoByID(id);
    }

    @Override
    public void updateStatus(Integer id, Integer status) {
        CompanyAsset asset = new CompanyAsset();
        asset.setId(id);
        asset.setStatus(status);
        companyAssetMapper.updateByPrimaryKeySelective(asset);
    }
}
